<!-- xml version="1.0" encoding="utf-8" -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
	<title>English Verb Conjugator</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
	<link href="../classics.css" rel="stylesheet" type="text/css">
</head>
<?php

include "EnglishConjugator.php";

function validateForm() {
	return ($_SERVER['REQUEST_METHOD'] == 'POST') && $_POST['everb'];
}

$defaults['everb'] = '';

if (validateForm()) {
	$defaults['everb'] = $_POST['everb'];
}
?>

<body>
<div class="center">
<form action="<?php echo $_SERVER['SCRIPT_NAME'] ?>" method="POST">
English Verb: <input name="everb" type="text" value="<?php echo $defaults['everb']; ?>"/>
<input type="submit" value="Submit" />
</form>
</div>
<?php
if (validateForm()) {
	$leverbs = array();
	$voices = array('active', 'passive');
	$moods = array('indicative', 'subjunctive', 'imperative');
	$tenses = array('present', 'imperfect', 'future', 'perfect', 'pluperfect', 'future perfect');
	$persons = array('I', 'thou', 'he', 'we', 'ye', 'they');
	foreach($voices as $voice) {
		foreach($moods as $mood) {
			foreach($tenses as $tense) {
				foreach($persons as $person) {
					$nverb = lv2ev($_POST['everb'], $voice, $mood, $tense, $person);
					if ($nverb) {
						$leverbs[$voice][$mood][$tense][$person] = $nverb;
					}
				}
			}
		}
	}
	
	$tenses = array('present', 'future', 'perfect', 'gerundive');

	foreach($voices as $voice) {
		foreach($tenses as $tense) {
			$nverb = lv2evInfi($_POST['everb'], $voice, $tense);
			if ($nverb) {
				$leverbsInfi[$voice][$tense] = $nverb;
			}
		}
	}

	foreach($voices as $voice) {
		foreach($tenses as $tense) {
			$nverb = lv2evPart($_POST['everb'], $tense);
			if ($nverb) {
				$leverbsPart[$tense] = $nverb;
			}
		}
	}
	
	$types = array('gerund', 'supine');
	$cases = array('genitive', 'dative', 'accusative', 'ablative');
	$leverbsNouns = array();
	foreach($types as $type) {
		foreach($cases as $case) {
			$nverb = lv2evNoun($_POST['everb'], $type, $case);
			if ($nverb) {
				$leverbsNouns[$type][$case] = $nverb;
			}
		}
	}
	print "<hr />\n<pre>\n";
	print_r($leverbsNouns);
	print "</pre>\n";
}

?>
</body>
</html>
